
import org.junit.jupiter.api.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-12-22
 * Time: 11:44
 */
//测试redis集群
public class Test_Cluster {
    @Test
    public  void cluster() {
        //搭建集群
        Set<HostAndPort> set=new HashSet<>();
        set.add(new HostAndPort("101.35.154.52", 7001));
        set.add(new HostAndPort("101.35.154.52", 7002));
        set.add(new HostAndPort("101.35.154.52", 7003));
        set.add(new HostAndPort("101.35.154.52", 7004));
        set.add(new HostAndPort("101.35.154.52", 7005));
        set.add(new HostAndPort("101.35.154.52", 7006));
        //连接
        JedisCluster jedisCluster=new JedisCluster(set);
        jedisCluster.set("name","ljp");
        System.out.println(jedisCluster.get("name"));
    }
}
